package com.global.college.adapter;

import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.global.college.R;
import com.global.college.data.net.MyCourseListBean;
import com.global.college.ui.activity.CourseDetailActivity;
import com.global.college.utils.StringUtils;
import com.global.college.widget.FrescoImageView;

/**
 * Author by xuyangsheng,  Date on 2024/7/17.
 * Explain：
 * 布局：item_study_course
 */
public class StudyCourseAdapter extends BaseQuickAdapter<MyCourseListBean.MyCourseBean, BaseViewHolder> {

    public StudyCourseAdapter() {
        super(R.layout.item_study_course);
    }

    @Override
    protected void convert(BaseViewHolder holder, MyCourseListBean.MyCourseBean courseBean) {

        RelativeLayout rela_study_course = holder.getView(R.id.rela_study_course);
        holder.getAdapterPosition();
        holder.setText(R.id.title_name,courseBean.getName()+""+(holder.getAdapterPosition()+1));

        if((holder.getAdapterPosition()) % 3 == 0){
            rela_study_course.setBackgroundResource(R.drawable.my_course_zi);
        }else if((holder.getAdapterPosition()) % 3 == 1){
            rela_study_course.setBackgroundResource(R.drawable.my_course_lu);
        }else if((holder.getAdapterPosition()) % 3 == 2){
            rela_study_course.setBackgroundResource(R.drawable.my_course_hong);
        }

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mContext.startActivity(new Intent(mContext, CourseDetailActivity.class)
                        .putExtra("classId",courseBean.getClassId()));
            }
        });


/*        FrescoImageView fivCover = holder.getView(R.id.fiv_cover);
        TextView tvTitle = holder.getView(R.id.tv_title);
        TextView tvStatusTag = holder.getView(R.id.tv_status_tag);
        TextView tvStudyTime = holder.getView(R.id.tv_study_time);
        TextView tvStudyStatus = holder.getView(R.id.tv_study_status);
        TextView tvStudyProgress = holder.getView(R.id.tv_study_progress);
        TextView tvDetail = holder.getView(R.id.tv_detail);
        TextView tvContinueStudy = holder.getView(R.id.tv_continue_study);
        fivCover.setImageURI(courseBean.getCover());
        tvTitle.setText(courseBean.getName());
        if (courseBean.getClassState() == 0) {
            tvStatusTag.setText("更新中");
        } else {
            tvStatusTag.setText("已完结");
        }
        tvStudyTime.setText("学习时长：" + courseBean.getStudyTime() / 60 + "分钟");
        if (courseBean.getStudySpeed() == 1) {
            tvContinueStudy.setVisibility(View.GONE);
            tvDetail.setVisibility(View.VISIBLE);
            tvStudyStatus.setTextColor(Color.parseColor("#212121"));
            tvStudyStatus.setText("已学完");
        } else {
            tvContinueStudy.setVisibility(View.VISIBLE);
            tvDetail.setVisibility(View.GONE);
            tvStudyStatus.setTextColor(Color.parseColor("#f63042"));
            tvStudyStatus.setText("已学" + String.format("%.1f", (courseBean.getStudySpeed() * 100)) + "%");
        }
        if (!StringUtils.isEmpty(courseBean.getVideoName())){
            tvStudyProgress.setText("学至：" + courseBean.getVideoName());
        }*/

    }


}
